#include "find_first_custom_vertex.h"
#include "find_first_custom_vertex_demo.impl"

#include "create_custom_vertices_k2_graph.h"
#include "create_empty_directed_custom_vertices_graph.h"
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(find_first_custom_vertex_thorough)
{
  const auto g = create_custom_vertices_k2_graph();
  {
    // Find A by name
    const auto vd = find_first_custom_vertex(
      [](const my_custom_vertex& v) { return v.get_name() == "A"; }, g);
    BOOST_CHECK(get_my_custom_vertex(vd, g).get_description() == "source");
  }

  {
    // Find B by x coordinat
    const auto vd = find_first_custom_vertex(
      [](const my_custom_vertex& v) { return v.get_x() > 3.0; }, g);
    BOOST_CHECK(get_my_custom_vertex(vd, g).get_name() == "B");
  }
}

BOOST_AUTO_TEST_CASE(find_first_custom_vertex_when_vertex_is_absent)
{
  const auto g = create_empty_directed_custom_vertices_graph();

  BOOST_CHECK_THROW(
    find_first_custom_vertex(
      [](const my_custom_vertex& v) { return v.get_name() == "absent"; }, g),
    std::invalid_argument);
}
